const http = require('http');

const server = http.createServer((req, res) => {
    console.log(req.headers.host, "headers.host");

    if (req.url === '/user') {
        res.writeHead(200, { 'Content-Type': 'application/json' });
        res.end(JSON.stringify({
            code: 200,
            message: "success",
            data: {
                name: '张三',
                age: 18
            }
        }));
    }
})

server.listen(3000, () => {
    console.log('server is running at http://localhost:3000')
})